package com.yt.lxh.activity.api;

import com.yt.lxh.activity.service.CouponInfoService;
import com.yt.lxh.activity.service.CouponUseService;
import com.yt.lxh.vo.activity.coupon.UserOwnCouponVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/coupons")
public class CouponApiController {

    @Autowired
    private CouponInfoService couponInfoService;

    @Autowired
    private CouponUseService couponUseService;

    @GetMapping("/add/{userId}/{couponId}")
    public void createUserCouponBy(@PathVariable("userId") String userId, @PathVariable("couponId") String couponId) {
        couponUseService.receiveCoupon(userId, couponId);
    }

    @GetMapping("/list/{userId}")
    List<UserOwnCouponVO> getCouponListByUserId(@PathVariable("userId") String id) {
        return couponInfoService.getCouponListByUserId(id);
    }

}
